package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CommonReviewInfo;
import com.ruoyi.business.service.ICommonReviewInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通用审核记录Controller
 * 
 * @author asher
 * @date 2021-11-17
 */
@RestController
@RequestMapping("/business/review_info")
public class CommonReviewInfoController extends BaseController
{
    @Autowired
    private ICommonReviewInfoService commonReviewInfoService;

    /**
     * 查询通用审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:review_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommonReviewInfo commonReviewInfo)
    {
        startPage();
        List<CommonReviewInfo> list = commonReviewInfoService.selectCommonReviewInfoList(commonReviewInfo);
        return getDataTable(list);
    }

    /**
     * 导出通用审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:review_info:export')")
    @Log(title = "通用审核记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CommonReviewInfo commonReviewInfo)
    {
        List<CommonReviewInfo> list = commonReviewInfoService.selectCommonReviewInfoList(commonReviewInfo);
        ExcelUtil<CommonReviewInfo> util = new ExcelUtil<CommonReviewInfo>(CommonReviewInfo.class);
        return util.exportExcel(list, "通用审核记录数据");
    }

    /**
     * 获取通用审核记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:review_info:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(commonReviewInfoService.selectCommonReviewInfoByRecordId(recordId));
    }

    /**
     * 新增通用审核记录
     */
    @PreAuthorize("@ss.hasPermi('business:review_info:add')")
    @Log(title = "通用审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommonReviewInfo commonReviewInfo)
    {
        return toAjax(commonReviewInfoService.insertCommonReviewInfo(commonReviewInfo));
    }

    /**
     * 修改通用审核记录
     */
    @PreAuthorize("@ss.hasPermi('business:review_info:edit')")
    @Log(title = "通用审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommonReviewInfo commonReviewInfo)
    {
        return toAjax(commonReviewInfoService.updateCommonReviewInfo(commonReviewInfo));
    }

    /**
     * 删除通用审核记录
     */
    @PreAuthorize("@ss.hasPermi('business:review_info:remove')")
    @Log(title = "通用审核记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(commonReviewInfoService.deleteCommonReviewInfoByRecordIds(recordIds));
    }
}
